using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iopt.solvency.pillarone.client.desktop.Views;
using Microsoft.VisualBasic;
using System.Collections;
using System.Diagnostics;
using System.Xml.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;

namespace iopt.solvency.pillarone.client.desktop.ViewModels
{
    public class ModelPropertyDefinition : ModelElementDefinition
    {
    
        public ModelPropertyDefinition()
        {
            Type = ModelParamUnderLyingType.Double;
            this.Details = new ObservableCollection<Detail>();
            CreateDetails();
        }
    
        public bool IsKey { get; set; }
        public ModelParamUnderLyingType Type { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
    
        public ObservableCollection<Detail> Details { get; private set; }
    
        public class Detail
        {
            public string Name { get; set; }
            public object Value { get; set; }
            public Type Type { get; set; }
            public bool Visible { get; set; }
        }
    
        private void CreateDetails()
        {
            Details.Add(new Detail
            {
                Name = "Légende",
                Value = "Nom Affiché",
                Type = typeof(string),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Peut Segmenter",
                Value = false,
                Type = typeof(bool),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Format en Entrée",
                Value = "",
                Type = typeof(string),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Format en Sortie",
                Value = "",
                Type = typeof(string),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Type Exact en Entrée",
                Value = "",
                Type = typeof(string),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Contrainte",
                Value = "",
                Type = typeof(string),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Valeur Si Erronée",
                Value = "",
                Type = typeof(string),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Valeur Manquante Interdite",
                Value = true,
                Type = typeof(bool),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Est Calculé",
                Value = false,
                Type = typeof(bool),
                Visible = true
            });
            Details.Add(new Detail
            {
                Name = "Formule De Calcul",
                Value = "=",
                Type = typeof(string),
                Visible = true
            });
        }
    
    
        protected internal override System.Xml.Linq.XElement GetXml()
        {
            dynamic q = from d in Details select new XElement("Detail", new XAttribute("Name", d.Name), new XAttribute("Type", d.Type), new XAttribute("Visible", d.Visible), new XAttribute("Value", d.Value));
    
            dynamic propxml = new XElement("Property", new XAttribute("Name", Name), new XAttribute("Type", Type), new XAttribute("IsKey", IsKey), new XAttribute("Description", Description), q);
    
            return propxml;
        }
    }
}
